﻿using API_Service.BizLogic.Kanban;
using API_Service.BizLogic.WIPControl;
using Nancy;

namespace API_Service.Module
{
    public class ReportModule:BaseAPIModule
    {
        private StationRecService _stationRec = new StationRecService();
        private WIPTrackingService _wipService = new WIPTrackingService();

        public ReportModule() : base("reports")
        {
            Get["/"] = _ => Response.AsJson("报表查询服务");

            Get["/stationrec/"] = _ =>
            {
                ExecutionResult<dynamic> result;
                result = new ExecutionResult<dynamic>();
                dynamic quertCondition = new
                {
                    work_date = Request.Query.work_date,
                    line = Request.Query.line,
                    mo = Request.Query.mo,
                    model = Request.Query.model,
                    group = Request.Query.group
                };

                result = _stationRec.QueryStationRecInfo(quertCondition);

                return Response.AsJson(result);
            };

            Get["/wiptracking/"] = _ =>
            {
                dynamic _qcondition =
                    new
                    {
                        sn = Request.Query.sn,
                        mo = Request.Query.mo,
                        model = Request.Query.model,
                        sku = Request.Query.sku,
                        group = Request.Query.group,
                        line = Request.Query.line,
                        start_time = Request.Query.start_time,
                        end_time = Request.Query.end_time
                    };
                ExecutionResult<dynamic> result;
                result = new ExecutionResult<dynamic>();
                result = _wipService.GetWIPTrackingInfo(_qcondition);

                return Response.AsJson(result);
            };
        }

    }
}